package com.oJudge.judge;

import com.oJudge.judge.strategy.DefaultJudgeStrategy;
import com.oJudge.judge.strategy.JavaJudgeStrategy;
import com.oJudge.judge.strategy.JudgeContext;
import com.oJudge.judge.strategy.JudgeStrategy;
import com.oJudge.judge.codeSandbox.modal.JudgeInfo;
import com.oJudge.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * 判题管理器
 */
@Service
public class JudgeManager {


    /**
     * 执行判题
     *
     * @param judgeContext
     * @return
     */

    public JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy judgeStrategy = new DefaultJudgeStrategy();
        //匹配多个策略的
        switch (language) {
            case "java":
                judgeStrategy = new JavaJudgeStrategy();
                break;
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
